<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<table id="a" border="1"></table>
<input type="button" value="添加行" onclick="add()"/>
<input type="button" value="删除行" onclick="dl()"/>
<script>
	var bq=document.getElementById("a");
	for(var i=0;i<3;i++){
		var tr=document.createElement("tr");
		for(var j=0;j<3;j++){
			var td=document.createElement("td");
			td.style.height="20px";
			td.style.width="20px";
			tr.appendChild(td);
			}
		bq.appendChild(tr);
		}
	function add(){
		var tr=bq.lastChild.cloneNode(true);
		bq.appendChild(tr);
		
		
		}
	function dl(){
		if(bq.children.length==1){
			alert("最后一个了，不可删除");
		
			}
		else{
			bq.removeChild(bq.lastChild);
		}
		
		}





</script>
</body>
</html>
